//
//  ZJTipsBtn.m
//  ZiJinLian
//
//  Created by lc on 2017/3/23.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "ZJTipsBtn.h"

@implementation ZJTipsBtn

-(instancetype)initWithZJTipsBtn:(NSString *)title image:(NSString *)image{
    if (self = [super init]) {
        self.backgroundColor=[UIColor whiteColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = FontAndStyle14;
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:TextColor3 forState:UIControlStateNormal];
        [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
//        [self setImageEdgeInsets:UIEdgeInsetsMake(-10, 0, 0, 0)];
        
        _number=[[UILabel alloc]init];
        _number.textColor=button_Red_Color;
        _number.font=FontAndStyle12;
        _number.layer.borderWidth=1;
        _number.layer.borderColor=button_Red_Color.CGColor;
        _number.textAlignment=NSTextAlignmentCenter;
        _number.layer.cornerRadius=17/2.0;
        _number.clipsToBounds=YES;
        [_number setHidden:YES];
        [self addSubview:_number];
        [_number mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).offset(-MainW/16);
            make.top.equalTo(self.mas_top).offset(MainW/32-5);
            make.width.mas_equalTo(17);
            make.height.mas_equalTo(17);
        }];
    }
    return self;
}




-(void)addNumber:(NSString*)num{
    if(_number){
        _number.text=num;
        [_number setHidden:NO];
    }
}

-(void)hideTips:(BOOL)hide{
    if (_number) {
        [_number setHidden:YES];
    }
}






-(void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.bsg_y = 10;
    self.imageView.bsg_centerX=self.bsg_width/2;
    self.titleLabel.bsg_x=0;
    self.titleLabel.bsg_y=self.imageView.bsg_bottom-10;
    self.titleLabel.bsg_height=self.bsg_height-self.imageView.bsg_height;
    self.titleLabel.bsg_width=self.bsg_width;
}

@end
